<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>${title}</title>
 	<link rel="stylesheet" href="${basePath}/static/css/bootstrap.css"/> 
    <link href="${basePath}/static/css/login.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/basic.css" rel="stylesheet" type="text/css">
    <link href="${basePath}/static/css/list.css" rel="stylesheet" type="text/css">
    <script  type="text/javascript" src="${basePath}/static/js/jquery.min.js"></script>
	<script  type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="${basePath}/static/page/jqPaginator/jqPaginator.js"></script>
    <script type="text/javascript" src="${basePath}/static/js/easydialog.min.js"></script>
    <script type="text/javascript" src="${basePath}/static/js/util.js"></script>
    <script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
	<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">
    
    <style>
    .input_box3{height:28px;width:300px;}
   .filePage{
    width:100%;
    height:1000px;
    border:1px solid #ccc;
    background: #505050;
    overflow-y:scroll;
    overflow-x: hidden;
    margin-bottom: 10px;
	}
	.filePage ul{
	    padding:10px 50px;
	}
	.filePage ul li{
	    border:4px solid #ccc;
	    margin-bottom:10px;
	}
	.filePage ul li img{
	    width:100%;
	    height:100%;
	}
    </style>
</head>
<body>
<!--内容部分-->
<div class="list_main lay_out" class="clearfix">
    <div style="width:100%; height:auto;margin-top:15px;margin-left:1%;">
        <div class="loc">
            <h3 style="margin:0 0;font-size:18px;">质控评分</h3>
        </div>
        <div class="list_con_table">
            <div class="search_table">
                <ul>
                     <input class="input_box" type="hidden"   name='' id='operator' value='${operator}' />
                	 <input class="input_box" type="hidden"   name='' id='uniqueKey' value='${medicalRecord.firstGuid}' />
                	 <input class="input_box" type="hidden"   name='' id='qualityPatientName' value='${patientName }' />
                     <input class="input_box" type="hidden"   name='' id='qualityMrId' value='${medicalSearchVO.mrId }' />
                     <input class="input_box" type="hidden"   name='' id='qualityOnlyId' value='${medicalSearchVO.onlyId }' />
                     <input class="input_box" type="hidden"   name='' id='qualityStartTime' value='${startTime}' />
                     <input class="input_box" type="hidden"   name='' id='qualityEndTime' value='${endTime}' />
                     <input class="input_box" type="hidden"   name='' id='qualityOutoffice' value='${medicalSearchVO.outHospitalOfficeId}' />
                     <input class="input_box" type="hidden"   name='' id='qualityIdCard' value='${medicalSearchVO.idCard}' />
                    <li class="Label_1">姓名：&nbsp;</li>
                    <li class="Label_2">
                    ${medicalRecord.name}
                    <!--  <input class="input_box" type="text" disabled="disabled"  name='' id='' value='${medicalRecord.name}' />-->
                    </li>
                    <li class="Label_1">识别码：&nbsp;</li>
                    <li class="Label_2">
                    ${medicalRecord.mrId}
                    <!--  <input class="input_box" type="text"  disabled="disabled" name='' id='controlName' value='${medicalRecord.mrId}' />-->
                    </li>
                    <li class="Label_1">身份证：&nbsp;</li>
                    <li class="Label_2">
                    ${medicalRecord.idNumber}
                    <!--  <input class="input_box" type="text"  name='' id='' value='${medicalRecord.idNumber}' />-->
                    </li>
                    <li class="Label_1 " style="height:114px; line-height:114px;">质控项目：&nbsp;</li>
                    <li class="Label_4" style="width:52.98%;height:114px;padding-left:2px;">
                        <select class="input_box input_box3" onchange="getSecondProject()" name="" id="firstPro">
                            <option value="">-----  选择评价项目  -----</option>
                            <c:forEach var="firstStandard" items="${firstStands}">
                        		<option value="${firstStandard.id}">${firstStandard.project}</option>
                       		</c:forEach>
                        </select>
                        <br/>
                        <select class="input_box input_box3" onchange="thirdProject()" name="" id="secondPro">
                            <option value="">-----  选择二级评价项目 -----</option>
                          
                        </select>
                        <br/>
                        <select class="input_box input_box3" onchange="getProjectMsg()"  name="" id="thirdPro">
                            <option value="">----- 选择三级评价项目 -----</option>
                         
                        </select>
                    </li>
                    <li class="Label_1"style="height:114px;line-height:114px;">扣分:</li>
                    <li class="Label_2" style="height:114px;line-height:114px;">
                        <input type="text" class="input_box" name='' id='qcDockPoints' value=''/>
                    </li>
                    <li class="Label_1" style="height:118px;line-height:118px;">质控描述：&nbsp;</li>
                    <li class="Label_4" style="width:86%;height:114px;padding:2px;">
                      <textarea id="medControlDesc" style="width:100%;height:90px;margin-top:10px;border: #e3e5e4 solid 1px"></textarea>
                    </li>
                    
                   
                    <li class="Label_5">
                        <div class="right" >
                       <%--  <c:choose>  
						   <c:when test="${qualityList[0].qualityStatus==2}">      
	                         	<a id="Edit">短信通知</a>
						   </c:when>  
						   <c:otherwise>   --%>
						  <!--  <a id="Edit">短信通知</a> -->
						   
                           <%--  <a  href="${basePath}/quality/qualitySearch?folderName=${folderName}">完成</a> --%>
                            <a  class="completeQuality" id="Add" onclick="completeQuality(this)" firstGuid="${medicalRecord.firstGuid}">质控完成</a>
							<a id="Add" onclick="addQuality()">添加质控</a>
                         	<a style="width:auto;"onclick="skan()">查看患者数据</a>
                         	<%-- <a style="width:auto;" href="${corePath}/medical_record/print?visitGuid=${medicalRecord.firstGuid}">查看病案</a> --%>
                        </div>
                    </li>
                </ul>
            </div>
            
               <div id="imgs" class="filePage" style="height: 900px;">
			    	
    	</div>
			 <table class="Search_tableList" cellpadding="0" cellspacing="0" style="margin-bottom: 100px;">
                <tr>
                    <td class="tdLabel_4">姓名</td>
                    <td class="tdLabel_4">身份证</td>
                    <td class="tdLabel_4">识别码</td>

                    <td class="tdLabel_4">扣分项</td>
                    <td class="tdLabel_4">扣分</td>
                     <td class="tdLabel_4">质控描述</td>
                    <td class="tdLabel_4">质控人</td>
                    <td class="tdLabel_4">操作</td>
    

                </tr>

                 <c:forEach items="${qualityList}" var="medQuality">
                 <tr>
         
                    <td class="tdLabel_5">${medQuality.name}</td>
                    <td class="tdLabel_5">${medQuality.idCard}</td>
                    <td class="tdLabel_5">${medQuality.mrId}</td>
                    <td class="tdLabel_5">${medQuality.project}</td>
                    <td class="tdLabel_5">${medQuality.score}</td>
                     <td class="tdLabel_5">${medQuality.qualityDes}</td>
                    <td class="tdLabel_5">${medQuality.qualityName}</td>
                    <td class="tdLabel_5"><a class="int"  mqId="${medQuality.mqId}" mqcId="${medQuality.medQuaFunId}" onclick="deleteQuality(this)">删除</a></td>
                
                </tr>
                </c:forEach>
                

             
            </table> 
        </div>
    
    </div>
<!------页脚部分--------->


</div>


<style>
	/*-------弹出页样式------*/
#div_TC{
    width:90%;height:auto; background:#FFF; border-radius:5px; margin:0 auto; overflow:hidden;display:none;
}
.TC_title{
    width:100%; height:50px; background:#009388;
}
.TC_title h3{
    font-family:"幼圆"; font-size:17px; color:#fff; font-weight:bold; line-height:50px; text-indent:32px; float:left;
}
.TC_title ul{
    width:80px; height:32px; float:right; margin-top:9px;
}
.TC_title ul li{
    width:76px; height:32px; font-family:"幼圆"; font-size:16px; color:white; line-height:32px; text-align:center; border:0; background:url(../../publics/images/but.png) no-repeat; float:left; margin-right:14px;
}
.TC_title ul li input{
    cursor:pointer; display: block;width:100%;height:100%;font-size:14px;
}
.TC_search_table{
    width:90%; height:246px;
}
.TC_search_table li{
	margin-top:5px;
    margin-left: 20px;
    font-size: 16px;
    font-family: 幼圆;
}
.TC_li{
    background:url(../../publics/images/sidebar2-2.png) no-repeat; margin-bottom:4px; float:left;
}
.TC_current{
    color:#6c6f6f; background:url(../../publics/images/sidebar2-1.png) no-repeat;
}
.TC_foot{
    width:100%; height:54px; background:#d8d9d9; float:left;
}
.TC_foot ul{
    width:100%; height:32px; float:right; margin-top:11px;
}
.TC_foot ul li{
    margin:0 auto; width:172px; height:32px; font-family:"微软雅黑"; font-size:14px; color:#ffffff; line-height:32px; text-align:center; border:0;
}
.TC_foot ul li a{
    color:#ffffff; cursor:pointer; display: block;width:76px;float:left;margin:0 5px;
}
#div_TC tr:nth-of-type(2n) .tdLabel_8{
    background-color: #F5F5F5;
}
#div_TC tr td{
    border:1px solid #D5DDDD;
}
.tdLabel_7 {
    text-align:center; width:86px; height:35px; line-height:35px; font-family:"微软雅黑"; font-size:14px; color:#010000; background:#e3e5e4; border:#e5e5e5 1px solid;
}
.tdLabel_8 {
    text-align:left; width:240px; height:35px; line-height:35px; padding:2px 0 2px 5px;font-family:"微软雅黑"; font-size:14px; color:#020202; background:#ffffff; border:#e5e5e5 1px solid;
}
.tdLabel_8 input[type="text"]{
    height:30px;
    background-color: #fff;
    border:none;
    border-bottom: 1px solid #FFC99D;
}
.tdLabel_8 input[type="radio"]{
    height:30px;
    width:16px;
    vertical-align: middle;
}
.tdLabel_8 select{
    height:30px;
    width:160px;
    font-size:14px;
    border-color:#ccc;
    color:rgba(0,0,0,.8);
}
#closeBtn3{
	width:100px;
	height:40px;
	line-height:40px;
	text-align:center;
	font-size:16px;
	font-family:幼圆;
	background-color:#009287;
	color: white;
	border-radius:8px;
	display:inline-block;
	cursor: pointer;
	margin-top:10px;
	margin-left: 215px;
	text-decoration: none;
}
.backcolor{
	height:60px;
	width:100%;
	background-color: #D8D9D9;
}
.changeinputCss{border: 1px red solid;}
</style>
<!-- 新增弹出框-->
<div id="div_TC">
    <div class="TC_title">
       <h3 style="margin:0">短信通知</h3>
        <ul>
            <li><a id="closeBtn2">取消</a></li>
        </ul>
    </div>
    <div class="TC_search_table">
        <ul>
            <li>手机号：
            	<input class="input_box" type=""  name='' id='phoneNumber' value='' title=''/>
            </li>
            <li>短信内容：
            	<textarea cols="60" rows="7" width="100%" height="90%" id="messageContent" title=''></textarea>
            </li> 
        </ul>
    </div>
    <div class="backcolor">
        <ul>
            <li><a id="closeBtn3" onclick="notice()">通知</a></li>
        </ul>
    </div>
</div>
<input type="hidden" value="${medicalRecord.firstGuid}" id="firstGuid">
<!--JS部分-->
<script>
   
   	$(function() {
   		var firstGuid = $("#firstGuid").val();
   		showPaginationPicture(firstGuid);
   		
   	});
   	
   	//显示图片
   	function showPaginationPicture(firstGuid) {
   		console.log("----firstGuid--" + firstGuid);
   		$.ajax({
    		type:"get",
    		data:{firstGuid:firstGuid},
    		url:"${corePath}/medrecord/getMedicalFileListAjax",
    		success:function(data){
    			if (data.success) {
    				console.log(data);
    				 var scanFiles = data.data.scanFiles;
    				var hospitalizationNoteResourceUrl = data.data.hospitalizationNoteResourceUrl;
    				if (scanFiles != null && scanFiles.length > 0) {
    					var content = "<ul>";
    					
						for (var i = 0; i < scanFiles.length; i++) {
							var imgPath = hospitalizationNoteResourceUrl + scanFiles[i].fileUrl + scanFiles[i].fileName
							content+="<li><img src="+imgPath+"></li>";
						}    			
						content+="</ul>";
						$("#imgs").append(content);
    				} 
    				
    			}
    		}
    	}); //--------ajax end--------
   	}
   
    function getSecondProject(){
    	var parentId=$("#firstPro ").val();
    	$.ajax({
    		type:"post",
    		data:{parentId:parentId},
    		url:"${basePath}/quality/getQualityProjectList",
    		success:function(data){
    			if(data!=null){
    				$("#secondPro").html("");
    				var html=" <option value=''>-----  选择二级评价项目 -----</option>";
    				for(var i in data){
    					var pro=data[i];
    					html+="<option value='"+pro.id+"'>"+pro.project+"</option>"
    				}
    				$("#secondPro").html(html);
    			}else{
    				$("#secondPro").html("");
    			}
    		}
    	})
    	
    }
    
    
    function thirdProject(){
    	var parentId=$("#secondPro").val();
    	$.ajax({
    		type:"post",
    		data:{parentId:parentId},
    		url:"${basePath}/quality/getQualityProjectList",
    		success:function(data){
    			if(data!=null){
    				$("#thirdPro").html("");
    				var html=" <option value=''>-----  选择三级评价项目 -----</option>";
    				for(var i in data){
    					var pro=data[i];
    					html+="<option value='"+pro.id+"'>"+pro.project+"</option>"
    				}
    				$("#thirdPro").html(html);
    			}else{
    				$("#thirdPro").html("");
    			}
    		}
    	})
    	
    	
    }
    
    
    function getProjectMsg(){
    	var id=$("#thirdPro").val();
    	$.ajax({
    		type:"post",
    		data:{id:id},
    		url:"${basePath}/quality/getPointsStandardById",
    		success:function(data){
    			if(data!=null){
    				var score=data.score;
    				var point=score==null?0:score
    				//alert(point);
    				var total=$("#qcPoints").val();
    				
    				
    				$("#qcDockPoints").val(point);
    				$("#qcPoints").val(parseInt(total)-parseInt(point));
    			}
    		}
    	})
    	
    }
    //数据病案查看
    function skan(){
    	var guid=$("#uniqueKey").val();
    	window.open('${corePath}/medical_record/searchHomePageIndexForm?visitGuid='+guid);
    }
    
    //添加病案质控
    function addQuality(){
    	var qcDockPoints=0;
    	var firstGuid=$("#uniqueKey").val();
    	var controlName=$("#operator").val();
    	var medControlDesc=$("#medControlDesc").val();
    	qcDockPoints=$("#qcDockPoints").val();
    	var firstProId=$("#firstPro").val();
    	var secondProId=$("#secondPro").val();
    	var thirdProId=$("#thirdPro").val();
    	if(!thirdProId){
    		layer.alert("请选择评价项目!",{icon:7});
    		return;
    	}
    	if(!qcDockPoints){
    		layer.alert("扣分项不能为空!",{icon:7});
    		return;
    	}
    	$.ajax({
    		
    		type:"post",
    		data:{firstGuid:firstGuid,qcDockPoints:qcDockPoints,medControlDesc:medControlDesc,
    			firstProId:firstProId,secondProId:secondProId,thirdProId:thirdProId
    		},
    		url:"${basePath}/quality/addMedQualityCont",
    		success:function(data){
    			window.location.href="${basePath}/quality/detailControl?firstGuid="+firstGuid;
    		}
    	})
     
    }
    
    //删除质控信息
    function deleteQuality(obj){
    	
    	var mqcId=$(obj).attr("mqcId");
    	var mqId=$(obj).attr("mqId");
    	$.ajax({
    		type:"post",
    		url:"${basePath}/quality/deleteQuality",
    		data:{mqcId:mqcId,mqId:mqId},
    		success:function(data){
    			console.log(data);
    			if(data.success){
	    			$(obj).parents("tr").fadeOut("slow",function(){
						$(this).remove();
					});
    				
    			}else{
    				
    			}
    		}
    	})
    }
    
    
    function completeQuality(obj){
      
          var mrId=$("#qualityMrId").val();
          var onlyId=$("#qualityOnlyId").val();
          var outHospitalStartDate=$("#qualityStartTime").val();
          var outHospitalEndDate=$("#qualityEndTime").val();
          var outHospitalOfficeId=$("#qualityOutoffice").val();
          var name=$("#qualityPatientName").val();
          var idCard=$("#qualityIdCard").val();
        
        
        	  name=encodeURI(encodeURI(name));
        	
        	  
          
    	var uniqueKey=$(obj).attr("firstGuid");
    	$.ajax({
    		type:"post",
    		data:{uniqueKey:uniqueKey},
    		url:"${basePath}/quality/completeQuality",
    		success:function(data){
    			if(data.success){
    				layer.alert("质控完成",{icon:1});
    				$(".completeQuality").css({"display":"none"});
    				window.location.href="${basePath}/quality/qualitySearch?firstGuid="+uniqueKey;
    				//window.location.href="${basePath}/quality/qualitySearch?firstGuid="+uniqueKey+"&mrId="+mrId+"&onlyId="+onlyId+"&idCard="+idCard+"&outHospitalStartDate="+outHospitalStartDate+"&outHospitalEndDate="+outHospitalEndDate+"&name="+name+"&qualityStatus=quality&outHospitalOfficeId="+outHospitalOfficeId;
    			}else{
    				layer.alert(data.msg,{icon:5});
    			}
    		}
    	})
    }
    
    $('#Edit').on("click",function() {
        easyDialog.open({
            container: 'div_TC',
            fixed: true,
        });
        $('#closeBtn2').on("click", function () {
            easyDialog.close();
        })
    })
    
    function notice(){
    	var phoneNumber=$("#phoneNumber").val();
    	var messageContent=$("#messageContent").val();
    	var num=0;
		$("[title='']").focus(function() { 
   			$("[title='']").each(function() {
   		  		$("[title='']").removeClass("changeinputCss");
   		  		
   			});
   	 	});
			$("[title='']").each(function() {  
	              if ($(this).val()=="" || $(this).val()==null) {
	                    $(this).addClass("changeinputCss");
	                    num=1;
	              }
			});
			if(num>0){
				layer.alert("手机号和短信内容不能为空!",{icon:7});
				return;
			}
		
		if(regPhone(phoneNumber)==false){
			layer.alert("手机号码格式错误!",{icon:7});
			$("#phoneNumber").addClass("changeinputCss");
			return;
		}
    	layer.alert("短信已发出!",{icon:1});
    }
    
		
    
</script>
</body>
</html>